<template>
	<view class="u-page">
		<view v-for="item in editFormOptions" class="u-demo-block">
			<view v-if="item.field =='department' && item.field !='xname'" style="flex-flow: row;justify-content: flex-start;display: flex;">	
				<u-picker :show="show" :columns="depart" @confirm="confirm" @cancel="cancelHand"></u-picker>
				<u-button @click="show = true">{{item.title}}:{{editFormFields.department}}</u-button>
				<u-button  @click="save" size=normal text="提交"></u-button>
			</view>
			<view v-if="item.field =='xname' && item.field !='department'">
				<text class="u-demo-block__title">姓名（可选填）</text>
				 <u--input
				    placeholder="姓名（可选填）"
				    border="surround"
				    v-model="editFormFields.xname"
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<!-- <view v-if="item.field !='xname' && item.field !='department'">
				<text class="u-demo-block__title">{{item.title}}</text>
				<u-rate :count="count" v-model="editFormFields[item.field]"></u-rate>
				<u-divider text="" :dashed="true"></u-divider>
			</view> -->
			<view v-if="item.field =='q1'">
				<text class="u-demo-block__title">1、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="每次都能快速接听"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="偶尔无人接听"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="经常无人接听"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="偶尔有人接听"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="从无人接听"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a1'" v-show="editFormFields['q1']=='D' ||editFormFields['q1']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q2'">
				<text class="u-demo-block__title">2、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="两小时之内"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="四小时之内"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="八小时之内"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="八小时之后"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="无响应"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a2'" v-show="editFormFields['q2']=='D' ||editFormFields['q2']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q3'">
				<text class="u-demo-block__title">3、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="非常有效"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="有效"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本有效"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本无效"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="无效"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a3'" v-show="editFormFields['q3']=='D' ||editFormFields['q3']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q4'">
				<text class="u-demo-block__title">4、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="50%以上满足"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="50%满足"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="40%-50%满足"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="30%-40%满足"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="30%以下满足"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a4'" v-show="editFormFields['q4']=='D' ||editFormFields['q4']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q5'">
				<text class="u-demo-block__title">5、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="完全满足"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满足需求"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满足"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满足"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="无效果"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a5'" v-show="editFormFields['q5']=='D' ||editFormFields['q5']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q6'">
				<text class="u-demo-block__title">6、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="完全满足"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满足需求"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满足"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满足"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="无效果"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a6'" v-show="editFormFields['q6']=='D' ||editFormFields['q6']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q7'">
				<text class="u-demo-block__title">7、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="非常满意"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满意"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满意"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满意"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="很不满意"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a7'" v-show="editFormFields['q7']=='D' ||editFormFields['q7']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q8'">
				<text class="u-demo-block__title">8、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="非常满意"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满意"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满意"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满意"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="很不满意"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a8'" v-show="editFormFields['q8']=='D' ||editFormFields['q8']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q9'">
				<text class="u-demo-block__title">9、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="非常满意"
					  name="A"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满意"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满意"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满意"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="很不满意"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a9'" v-show="editFormFields['q9']=='D' ||editFormFields['q9']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='q10'">
				<text class="u-demo-block__title">10、{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="有很大进步"
				      name="A"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="有进步"
					  name="B"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="无进步"
					  name="C"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="略有退步"
					  name="D"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="退步较大"
					  name="E"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不知情，不予评价"
					  name="F"
					> </u-radio>
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='a10'" v-show="editFormFields['q10']=='D' ||editFormFields['q10']=='E'">
				<text class="u-demo-block__title">{{item.title}}</text>
				 <u--input
				    placeholder=''
				    border="surround"
				    v-model="editFormFields[item.field]"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
			<view v-if="item.field =='remark'">
				<text class="u-demo-block__title">11、{{item.title}}</text>
				 <u--input
				    placeholder='对数字化部提出您的宝贵意见'
				    border="surround"
				    v-model="editFormFields.remark"  
				  ></u--input>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
		</view>
		<view class="btns">
			<view class="btn">
				<u-button type="success" @click="save" shape="circle" text="提交"></u-button>
			</view>
			
		</view>
		<u-divider text="" :dashed="true"></u-divider>
	</view>
</template>

<script>
	import options from './it_surveyOptions.js';
	let _options = options();
	//_options.extend = extend;
	export default {
		data() {
			return {
				ip:'',
				opt:_options,
				editFormFields:_options.editFormFields,
				editFormOptions:_options.editFormOptions,
				count:5,
				value:3,
				depart:[['公司领导',
						'综合管理部',
						'人力资源部',
						'数字化部',
						'产品企划部',
						'财务部',
						'运营管理部',
						'采购中心',
						'战略发展部',
						'营销服务公司',
						'品质保证部',
						'汽车研究院',
						'制造中心']],
				show: false,
			}
		},
		onShow() {
					this.$nextTick(()=>{
						//this.$refs.form.reset();
						//this.$toast("表单已重置")
						for(var item in this.editFormFields){
							 if (item.substring(0,1)=='q'){
								this.editFormFields[item]='A';
							}
							//if(item=="q1")this.editFormFields[item]='A';
							//if(item=="q2")this.editFormFields[item]='A';
						}
					})
				
				},
				onBackPress(options) {//返回return 阻止按钮起效
					//console.log("kkkk");
				   /* if (options.from === 'navigateBack') {
				        return false
				    }
				    uni.navigateBack({
				        delta: 100
				    })*/
				    return true;//返回return 阻止按钮起效
				},
		methods: {
			viewClick() {
				//获取生成页面grid的对象
				console.log(this.$refs.grid.searchFormFields)
			},
			confirm(e) {
			                //console.log(e.value[0])
							this.editFormFields.department=e.value[0]
			                this.show = false
						},
			cancelHand(e){
				this.show = false
			},
			save(){
				for(var item in this.editFormFields)
				{
					//题目是q1 原因是a1
					if (item.substring(0,1)=='q' && (this.editFormFields[item]=='E' || this.editFormFields[item]=='D')){//过滤选E或者D的题目，必须要填原因
						let t=this.editFormOptions.find((x)=>{
							var tt="a"+item.substring(1);
							//console.log(tt);
							return (x.field==tt)})
						//console.log(t.title);
						if(this.editFormFields["a"+item.substring(1)]==""){
							this.$toast(t.title);
							return;
						}
						
					}
				}
				let savedata={//判断前端对象属性为数组 
								mainData:this.editFormFields,
								delKeys: null,
								detailData: null
									}
				this.savecheck();
				if (this.editFormFields.department==""){
					this.$toast("请选择部门");
					return;
				}
				this.http.post("/api/it_survey/Add", savedata, true).then((s) => {
										this.$toast("保存成功");
										uni.navigateTo({
											url: "/pages/mytable/it_survey/end_back"
										})
										})
			},
			savecheck(){
				//console.log(this.editFormFields);
				
			},
			/* getUserIP (onNewIP) { // 获取ip地址
			    let MyPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection
			    let pc = new MyPeerConnection({iceServers: []})
			    let noop = function () {}
			    let localIPs = {}
			    let ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g
			    function iterateIP (ip) {
			        if (!localIPs[ip]) onNewIP(ip)
			        localIPs[ip] = true
			    }
			    pc.createDataChannel('')
			    pc.createOffer().then(function (sdp) {
			        sdp.sdp.split('\n').forEach(function (line) {
			        if (line.indexOf('candidate') < 0) return
			        line.match(ipRegex).forEach(iterateIP)
			        })
			        pc.setLocalDescription(sdp, noop, noop)
			    }).catch(function (reason) {
			    // An error occurred, so handle the failure to connect
			    })
			    // seen for candidate events
			    pc.onicecandidate = function (ice) {
			        if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return
			        ice.candidate.candidate.match(ipRegex).forEach(iterateIP)
			    }
			}, */
		}
	}
</script>

<style>
</style>